﻿using System.Web;

namespace CooliteExamples.Core
{
    public static class ProcessController
    {
        private static string GetBaseUrl()
        {
            string baseUrl = HttpContext.Current.Request.ApplicationPath;
            if (!baseUrl.EndsWith("/"))
            {
                baseUrl += "/";
            }

            return baseUrl;
        }

        public static string GetMainLandingUrl()
        {
            return string.Format("{0}Pages/Default.aspx", GetBaseUrl());
        }

        #region Handler Inner Class
        public static class Handlers
        {
            public static class Book
            {
                public static string GetAllBooksHandlerUrl()
                {
                    return string.Format("{0}Handlers/Book/GetAllBooks.ashx", GetBaseUrl());
                }

                public static string GetAllBooksFromControllerHandlerUrl()
                {
                    return string.Format("{0}Handlers/Book/GetAllBooksFromController.ashx", GetBaseUrl());
                }

                public static string GetBooksForAuthorHandlerUrl()
                {
                    return string.Format("{0}Handlers/Book/GetBooksForAuthor.ashx", GetBaseUrl());
                }
            }

            public static class Author
            {
                public static string GetAuthorsHandlerUrl()
                {
                    return string.Format("{0}Handlers/Author/GetAuthors.ashx", GetBaseUrl());
                }

                public static string GetAuthorsForBookHandlerUrl()
                {
                    return string.Format("{0}Handlers/Author/GetAuthorsForBook.ashx", GetBaseUrl());
                }

                public static string GetAuthorForBookFromControllerHandlerUrl()
                {
                    return string.Format("{0}Handlers/Author/GetAuthorsForBookFromController.ashx", GetBaseUrl());
                }

                public static string GetAvailableAuthorsForBookHandlerUrl()
                {
                    return string.Format("{0}Handlers/Author/GetAvailableAuthorsForBook.ashx", GetBaseUrl());
                }
            }

            public static class Category
            {
                public static string GetAllCategoriesHandlerUrl()
                {
                    return string.Format("{0}Handlers/Category/GetAllCategories.ashx", GetBaseUrl());
                }
            }
        }
        #endregion

        #region Services
        public static class Service
        {
            public static class Book
            {
                public static string GetAllBooksServiceUrl()
                {
                    return string.Format("{0}Service/BookService.svc/GetAllBooks", GetBaseUrl());
                }
            }
        }
        #endregion

        public static class Communication
        {
            public static string GetStoreExampleUrl()
            {
                return string.Format("{0}Pages/Communication/StoreExample.aspx", GetBaseUrl());
            }
        }

        public static class Control
        {
            public static string GetCreateFormExampleUrl()
            {
                return string.Format("{0}Pages/Control/CreateForm.aspx", GetBaseUrl());
            }

            public static string GetAuthorManageUrl()
            {
                return string.Format("{0}Pages/Control/AuthorManage.aspx", GetBaseUrl());
            }

            public static string GetGridPanelExampleUrl()
            {
                return string.Format("{0}Pages/Control/GridPanelExample.aspx", GetBaseUrl());
            }
        }

        #region Full Example Urls
        public static class FullExamples
        {
            public static string GetBookEntryUrl()
            {
                return string.Format("{0}Pages/BookEntry.aspx", GetBaseUrl());
            }
        }
        #endregion
    }
}
